home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / ADDINDEX.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-16  |  7.2 KB  |  234 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAddIndex 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Add Index"
  5.    ClientHeight    =   3495
  6.    ClientLeft      =   2100
  7.    ClientTop       =   4215
  8.    ClientWidth     =   5400
  9.    ForeColor       =   &H00000000&
  10.    HelpContextID   =   2016118
  11.    Icon            =   "Addindex.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   3067.929
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5311.688
  19.    ShowInTaskbar   =   0   'False
  20.    StartUpPosition =   1  'CenterOwner
  21.    Begin VB.CheckBox chkIgnoreNulls 
  22.       Caption         =   "IgnoreNulls"
  23.       Height          =   255
  24.       Left            =   3120
  25.       MaskColor       =   &H00000000&
  26.       TabIndex        =   5
  27.       Top             =   1320
  28.       Width           =   2188
  29.    End
  30.    Begin VB.CheckBox chkPrimary 
  31.       Caption         =   "Primary"
  32.       Height          =   255
  33.       Left            =   3120
  34.       MaskColor       =   &H00000000&
  35.       TabIndex        =   3
  36.       Top             =   360
  37.       Value           =   1  'Checked
  38.       Width           =   2188
  39.    End
  40.    Begin VB.TextBox txtIndexName 
  41.       BackColor       =   &H00FFFFFF&
  42.       Height          =   285
  43.       Left            =   120
  44.       TabIndex        =   0
  45.       Top             =   360
  46.       Width           =   2775
  47.    End
  48.    Begin VB.TextBox txtFields 
  49.       BackColor       =   &H00FFFFFF&
  50.       Height          =   525
  51.       Left            =   120
  52.       MultiLine       =   -1  'True
  53.       ScrollBars      =   2  'Vertical
  54.       TabIndex        =   1
  55.       Top             =   960
  56.       Width           =   2775
  57.    End
  58.    Begin VB.ListBox lstFields 
  59.       BackColor       =   &H00FFFFFF&
  60.       Height          =   1455
  61.       Left            =   120
  62.       Sorted          =   -1  'True
  63.       TabIndex        =   2
  64.       Top             =   1800
  65.       Width           =   2775
  66.    End
  67.    Begin VB.CheckBox chkUnique 
  68.       Caption         =   "Unique"
  69.       Height          =   252
  70.       Left            =   3120
  71.       MaskColor       =   &H00000000&
  72.       TabIndex        =   4
  73.       Top             =   840
  74.       Value           =   1  'Checked
  75.       Width           =   2188
  76.    End
  77.    Begin VB.CommandButton cmdOK 
  78.       Caption         =   "&OK"
  79.       Default         =   -1  'True
  80.       Enabled         =   0   'False
  81.       Height          =   375
  82.       Left            =   3240
  83.       MaskColor       =   &H00000000&
  84.       TabIndex        =   6
  85.       Top             =   2400
  86.       Width           =   1815
  87.    End
  88.    Begin VB.CommandButton cmdClose 
  89.       Cancel          =   -1  'True
  90.       Caption         =   "&Close"
  91.       Height          =   375
  92.       Left            =   3240
  93.       MaskColor       =   &H00000000&
  94.       TabIndex        =   7
  95.       Top             =   2880
  96.       Width           =   1815
  97.    End
  98.    Begin VB.Label lblLabels 
  99.       AutoSize        =   -1  'True
  100.       Caption         =   "Available Fields: "
  101.       Height          =   195
  102.       Index           =   2
  103.       Left            =   120
  104.       TabIndex        =   10
  105.       Top             =   1560
  106.       Width           =   1200
  107.    End
  108.    Begin VB.Label lblLabels 
  109.       AutoSize        =   -1  'True
  110.       Caption         =   "Indexed  Fields:"
  111.       Height          =   195
  112.       Index           =   1
  113.       Left            =   120
  114.       TabIndex        =   9
  115.       Top             =   720
  116.       Width           =   1155
  117.    End
  118.    Begin VB.Label lblLabels 
  119.       AutoSize        =   -1  'True
  120.       Caption         =   "Name: "
  121.       Height          =   195
  122.       Index           =   0
  123.       Left            =   120
  124.       TabIndex        =   8
  125.       Top             =   120
  126.       Width           =   510
  127.    End
  128. Attribute VB_Name = "frmAddIndex"
  129. Attribute VB_Base = "0{4123FDB5-D012-11CF-9ED2-00AA00574745}"
  130. Attribute VB_GlobalNameSpace = False
  131. Attribute VB_Creatable = False
  132. Attribute VB_TemplateDerived = False
  133. Attribute VB_PredeclaredId = True
  134. Attribute VB_Exposed = False
  135. Option Explicit
  136. '>>>>>>>>>>>>>>>>>>>>>>>>
  137. Const FORMCAPTION = "Add Index"
  138. Const BUTTON1 = "&OK"
  139. Const BUTTON2 = "&Close"
  140. Const LABEL0 = "Name:"
  141. Const Label1 = "Indexed Fields:"
  142. Const Label2 = "Available Fields:"
  143. '>>>>>>>>>>>>>>>>>>>>>>>>
  144. Private Sub lstFields_Click()
  145.   Dim sTmp As String
  146.   sTmp = txtFields.Text
  147.   If Len(sTmp) = 0 Then
  148.     txtFields.Text = sTmp & lstFields
  149.   Else
  150.     txtFields.Text = sTmp & ";" & lstFields
  151.   End If
  152.   txtFields.Refresh
  153. End Sub
  154. Private Sub txtFields_Change()
  155.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  156. End Sub
  157. Private Sub txtFields_LostFocus()
  158.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  159. End Sub
  160. Private Sub txtIndexName_LostFocus()
  161.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  162. End Sub
  163. Private Sub cmdClose_Click()
  164.   Unload Me
  165. End Sub
  166. Private Sub Form_Load()
  167.   Dim tblTableDef As TableDef
  168.   Dim fld As Field
  169.   Dim i As Integer
  170.   Me.Caption = FORMCAPTION
  171.   cmdOK.Caption = BUTTON1
  172.   cmdClose.Caption = BUTTON2
  173.   lblLabels(0).Caption = LABEL0
  174.   lblLabels(1).Caption = Label1
  175.   lblLabels(2).Caption = Label2
  176.   If gbAddTableFlag Then
  177.     Me.Caption = Me.Caption & " to " & frmTblStruct.txtTableName
  178.     For i = 0 To frmTblStruct.lstFields.ListCount - 1
  179.       lstFields.AddItem frmTblStruct.lstFields.List(i)
  180.     Next
  181.   Else
  182.     Me.Caption = Me.Caption & " to " & StripConnect(gnodDBNode2.Text)
  183.     Set tblTableDef = gdbCurrentDB.TableDefs(StripConnect(gnodDBNode2.Text))
  184.     ListItemNames tblTableDef.Fields, lstFields, False
  185.   End If
  186.   If gsDataType <> gsMSACCESS Then
  187.     chkPrimary.Enabled = False
  188.     chkIgnoreNulls.Enabled = False
  189.     chkPrimary.Value = vbGrayed
  190.     chkIgnoreNulls.Value = vbGrayed
  191.   End If
  192.   SetDefaults
  193. End Sub
  194. Private Sub txtIndexName_Change()
  195.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  196. End Sub
  197. Private Sub cmdOK_Click()
  198.   Dim indIndexObj As Index
  199.   Dim tblTableDefObj As TableDef
  200.   Dim sTmp As String
  201.   On Error GoTo AddIndexErr
  202.   Screen.MousePointer = vbHourglass
  203.   Set indIndexObj = gtdfTableDef.CreateIndex(txtIndexName.Text)
  204.   With indIndexObj
  205.     .Fields = txtFields.Text
  206.     .Unique = chkUnique.Value
  207.     If gsDataType = gsMSACCESS Then
  208.       .Primary = IIf(chkPrimary.Value, True, False)
  209.       .IgnoreNulls = IIf(chkIgnoreNulls.Value = vbChecked, True, False)
  210.     End If
  211.   End With
  212.   'append the index to the global tabledef
  213.   'from the tblstruct form
  214.   gtdfTableDef.Indexes.Append indIndexObj
  215.   'add the index to the list
  216.   frmTblStruct.lstIndexes.AddItem txtIndexName.Text
  217.   'make the new item active
  218.   frmTblStruct.lstIndexes.ListIndex = frmTblStruct.lstIndexes.NewIndex
  219.   'clear the name and allow entry of another
  220.   SetDefaults
  221.   txtIndexName.SetFocus
  222.   Screen.MousePointer = vbDefault
  223.   Exit Sub
  224. AddIndexErr:
  225.   ShowError
  226. End Sub
  227. Private Sub SetDefaults()
  228.   txtIndexName.Text = vbNullString
  229.   If gsDataType = gsMSACCESS Then
  230.     txtFields.Text = vbNullString
  231.     chkUnique.Value = vbChecked
  232.   End If
  233. End Sub
  234.